/**
 * 
 */
package com.wgo.precise.client.ui.view.util;

import java.net.URL;

import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.hyperlink.URLHyperlink;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;

/**
 * @author petterei
 * @version $Id: URLHyperLinkListener.java,v 1.1 2006-03-07 19:45:51 petterei Exp $
 */
public class URLHyperLinkListener extends HyperlinkAdapter {
	/**
	 * @see org.eclipse.ui.forms.events.HyperlinkAdapter#linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent)
	 */
	@Override
	public void linkActivated(HyperlinkEvent e) {
		URLHyperlink link = new URLHyperlink(new Region(0,0), ((URL)e.getHref()).toExternalForm());
		link.open();
		/* (non-Javadoc)
		 * @see org.eclipse.jface.text.hyperlink.URLHyperlink#open()
		 */
		// if want to get rid of jface.text
//		String url = ((URL)e.getHref()).toExternalForm();
//		if (url != null) {
//			String platform= SWT.getPlatform();
//			if ("motif".equals(platform) || "gtk".equals(platform)) { //$NON-NLS-1$ //$NON-NLS-2$
//				Program program= Program.findProgram("html"); //$NON-NLS-1$
//				if (program == null) {
//					program= Program.findProgram("htm"); //$NON-NLS-1$
//				}
//				if (program != null) {
//					program.execute(url);
//				}
//			} else {
//				Program.launch(url);
//			}
//		}
	}
}
